package com.asl.website.sysCompanyInfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.asl.website.sysCompanyInfo.domain.CompanyInfoDTO;
import com.asl.website.sysJoinMain.domain.JoinUsDTO;
import com.asl.website.sysJoinMain.domain.SysJoinMain;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.asl.common.annotation.Log;
import com.asl.common.core.controller.BaseController;
import com.asl.common.core.domain.AjaxResult;
import com.asl.common.enums.BusinessType;
import com.asl.website.sysCompanyInfo.domain.SysCompanyInfo;
import com.asl.website.sysCompanyInfo.service.ISysCompanyInfoService;
import com.asl.common.utils.poi.ExcelUtil;
import com.asl.common.core.page.TableDataInfo;

/**
 * 企业信息Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@RestController
@RequestMapping("/sysCompanyInfo/sysCompanyInfo")
public class SysCompanyInfoController extends BaseController
{
    @Autowired
    private ISysCompanyInfoService sysCompanyInfoService;

    @GetMapping("/content")
    public AjaxResult getJoinUsContent(@RequestHeader(value = "Accept-Language", defaultValue = "zh-CN") String acceptLanguage) {
        List<SysCompanyInfo> contents = sysCompanyInfoService.selectSysCompanyInfoList(new SysCompanyInfo());
        if (contents.isEmpty()) {
            return AjaxResult.error("未配置页面内容");
        }

        return AjaxResult.success(new CompanyInfoDTO(contents.get(0), acceptLanguage));
    }

    /**
     * 查询企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCompanyInfo sysCompanyInfo)
    {
        startPage();
        List<SysCompanyInfo> list = sysCompanyInfoService.selectSysCompanyInfoList(sysCompanyInfo);
        return getDataTable(list);
    }

    /**
     * 导出企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:export')")
    @Log(title = "企业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyInfo sysCompanyInfo)
    {
        List<SysCompanyInfo> list = sysCompanyInfoService.selectSysCompanyInfoList(sysCompanyInfo);
        ExcelUtil<SysCompanyInfo> util = new ExcelUtil<SysCompanyInfo>(SysCompanyInfo.class);
        util.exportExcel(response, list, "企业信息数据");
    }

    /**
     * 获取企业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysCompanyInfoService.selectSysCompanyInfoById(id));
    }

    /**
     * 新增企业信息
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:add')")
    @Log(title = "企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCompanyInfo sysCompanyInfo)
    {
        return toAjax(sysCompanyInfoService.insertSysCompanyInfo(sysCompanyInfo));
    }

    /**
     * 修改企业信息
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:edit')")
    @Log(title = "企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCompanyInfo sysCompanyInfo)
    {
        return toAjax(sysCompanyInfoService.updateSysCompanyInfo(sysCompanyInfo));
    }

    /**
     * 删除企业信息
     */
    @PreAuthorize("@ss.hasPermi('sysCompanyInfo:sysCompanyInfo:remove')")
    @Log(title = "企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysCompanyInfoService.deleteSysCompanyInfoByIds(ids));
    }
}
